package com.googlecode.yoohoo.xmppcore.protocol.parsing.error;

import com.googlecode.yoohoo.xmppcore.protocol.IError;
import com.googlecode.yoohoo.xmppcore.protocol.parsing.IXmppParser;
import com.googlecode.yoohoo.xmppcore.protocol.parsing.IXmppParserFactory;
import com.googlecode.yoohoo.xmppcore.protocol.parsing.ProtocolKey;
import com.googlecode.yoohoo.xmppcore.protocol.stanza.error.StanzaError;
import com.googlecode.yoohoo.xmppcore.protocol.stream.error.StreamError;

public class ErrorParserFactory implements IXmppParserFactory<IError> {
	private XmppErrorType type;
	
	public ErrorParserFactory(XmppErrorType type) {
		this.type = type;
	}
	
	@Override
	public IXmppParser<IError> createParser() {
		return new ErrorParser(type);
	}

	@Override
	public ProtocolKey getProtocolKey() {
		if (XmppErrorType.STREAM == type) {
			return StreamError.PROTOCOL_KEY; 
		} else {
			return StanzaError.PROTOCOL_KEY;
		}
	}

}
